package com.charm.codes.nethard.interceptors;

import android.text.TextUtils;

import java.io.IOException;

import okhttp3.Interceptor;
import okhttp3.Request;
import okhttp3.Response;

/**
 *
 * @author tools
 * @date 2017/12/11
 */

public class HeaderInterceptor implements Interceptor {
    @Override
    public Response intercept(Chain chain) throws IOException {
        //请求头添加区分商机版还是交易版的标志 以便后台做关注功能
        //TODO
        String platform = "";
        //请求头添加设备名字
        //TODO
        String deviceName = "";
        if (deviceName == null || TextUtils.isEmpty(deviceName)){
            deviceName = "";
        }
        //TODO
        String appId = "";
        if(appId==null||TextUtils.isEmpty(appId)){
            appId="";
        }
        Request request = chain.request()
                .newBuilder()
                .addHeader("appId",appId)
                .addHeader("platform",platform)
                .addHeader("deviceName",deviceName)
                .build();
        return chain.proceed(request);
    }
}